package org.cyb.demo.service.impl;

import org.cyb.demo.dao.UserMapper;
import org.cyb.demo.domain.User;
import org.cyb.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("userService")
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public User login(User user) {
        return userMapper.selectByAccountAndPassword(user);
    }

    @Override
    public void add(User user) {
        userMapper.insert(user);

    }

    @Override
    public List<User> findByAccount(User user) {
        return userMapper.selectByAccount(user);
    }

    @Override
    public List<User> findByName(User user) {
        return userMapper.selectByName(user);
    }

    @Override
    public List<User> findAll() {
        return userMapper.selectAll();
    }

    @Override
    public void modify(User user) {
        userMapper.update(user);
    }

    @Override
    public void remove(User user) {
        userMapper.delete(user);
    }

    @Override
    public void delete(User user) {
        userMapper.delete(user);
    }
}
